package com.anolesoft.amljmes.restService.mapper;

import com.anolesoft.amljmes.restService.dto.MesBzzPtmlIerpDto;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface MesBzzPtmlIerpMapper {

    /**
     * 根据机型查询 erpuser.mes_bzz_ptml_basics表,限制条件为最高版次和机型
     *  */
    @Select("select * from erpuser.mes_bzz_ptml_basics where t.jixing = #{model} " +
            "and t.banben = (select max(t.banben) from erpuser.mes_bzz_ptml_basics t where t.jixing = #{model})")
    List<MesBzzPtmlIerpDto> querydifferent(String model);


    /**
     *  删除配套目录表原有机型数据
     *  */
    @Delete("delete mes_bzz_ptml where jixing = #{model}")
    int deletePtmlByJx(String model);

    /**
     * 将数据插入到配套目录表,历史数据删除,返回操作结果
     *  */
    @Insert("insert into mes_bzz_ptml(objuid,ierp_objuid,xuhao,fenxuhao,peitaomulubianhao,jixing,tuhao," +
            "lingjianmingcheng,futuhao,fulingjianmingcheng,leibie,mululeibie,zhuanye,peitaoshuliang," +
            "danwei,bili,chengzhidanweibianma,chengzhidanwei,yijiaodanwei,fengongluxian,gualiangzhuangqianshiyan," +
            "shiyongxingjiancha,jiguanwenjian,zhuanjizhuanpei,jiacikaishi,jiacijieshu,beizhu,wuliaohao," +
            "wuliaomingcheng,guige,paihao,jishuzhuangtai,jiliangdanwei,laiyuanleibie,gongyizhuangtai," +
            "guanjianjianbiaoji,jiaofuchejian,jieshouchejian,jiaofushunxu,fengcunfangfa,changdaihao,paigonghao,danjishu)" +
            " (select * from erpuser.mes_bzz_ptml_basics where t.jixing = #{model} " +
            "  and t.banben = (select max(t.banben) from erpuser.mes_bzz_ptml_basics t where t.jixing = #{model}))")
    int insertPtmlByJx(String model);


    /**
     * 移除最高版本以外的数据到历史数据表
     */

    /**
     * 传过来一个机型,根据机型查询最高版本的数据,将最高版本的数据同步到ptml表,同步之后返回同步结果
     */
}
